package response

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func ResponseOK(c *gin.Context) {
	response := gin.H{
		"success": true,
	}
	c.JSON(http.StatusOK, response)
}

func ResponseOKWithData(c *gin.Context, msg string, data interface{}, total int) {
	response := gin.H{
		"success": true,
		"msg":     msg,
		"total":   total,
	}
	if data != nil {
		response["data"] = data
	}
	c.JSON(http.StatusOK, response)
}

func ResponseFail(c *gin.Context) {
	response := gin.H{
		"success": false,
	}
	c.JSON(http.StatusOK, response)
}

func ResponseFailWithData(c *gin.Context, msg string, data interface{}, total int) {
	response := gin.H{
		"success": false,
		"msg":     msg,
		"total":   total,
	}
	if data != nil {
		response["data"] = data
	}
	c.JSON(http.StatusOK, response)
}
